//
//  RadioListViewCell.m
//  Car
//
//  Created by 何晓文 on 15/9/18.
//  Copyright (c) 2015年 朱鸿儒. All rights reserved.
//

#import "RadioListViewCell.h"

@implementation RadioListViewCell


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}


//cell重用
+ (instancetype)cellWithTableView:(UITableView *)tableView {

	static NSString *identifier = @"list";
	RadioListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
	if (!cell) {
		cell = [[[NSBundle mainBundle] loadNibNamed:@"RadioListViewCell" owner:nil options:nil] lastObject];
	}
	return cell;
}
- (void)setValueWithCurrentTime:(NSString *)currentTime listModel:(RadioListModel *)model {
	NSMutableArray *images = [[NSMutableArray alloc] init];
	for (int i = 0; i < 4; i++) {
		NSString *name = [NSString stringWithFormat:@"playNow_%d",i + 1];
		UIImage *image = [UIImage imageNamed:name];
		[images addObject:image];
	}
	
	self.userInteractionEnabled = NO;
	self.musicImage.animationImages = images;
	self.musicImage.animationDuration = 0.5;
	self.titleLabel.text = model.title;
	self.albumLabel.text = model.album;
	self.durationLabel.text = model.programtime;

	if ([currentTime compare: model.starttime] >= 0 && [currentTime compare: model.endtime] <= 0)
	{
		[self.musicImage startAnimating];
		self.backgroundColor = [UIColor yellowGreenColor];
		self.stateLabel.text = @"播放中";
	} else if([currentTime compare: model.starttime] < 0)
	{
		self.stateLabel.text = @"未播出";
		self.backgroundColor = [UIColor blueberryColor];
	}else
	{
		self.stateLabel.text = @"已结束";
		self.backgroundColor = [UIColor grayColor];
	}
	
	
	
}

//从Xib调用会调用
- (void)awakeFromNib {
	self.contentView.backgroundColor = [UIColor clearColor];
}

//纯代码创建会调用
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
	self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
	if (self) {
		
	}
	return self;
}

@end
